<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<script type="text/javascript">
var driverForm = true;
$("document").ready(function(){
	$("input[type=text]").css({
		"width":"200px",
		"text-align":"center"
	});
	$("input[type=password]").css({
		"width":"200px",
		"text-align":"center"
	});
});
function formCheck(){
    var form = window.document.f1;
    
    if(!form.password.value){
        alert("패스워드를 넣으세요");
        form.password.focus();
        return false;
    }
    if(!form.name.value){
        alert("이름을 넣으세요");
        form.name.focus();
        return false;
    }
}

function upgradeDriver(){
	if(driverForm){
		$("#modify_address").after("<tr><td>회원종류</td><td><input type=\"text\" name=\"memberType\" disabled value=\"운전자\"></input></td></tr><tr><td>차량번호</td><td><input type=\"text\" name=\"carRegNum\"></td></tr><tr><td>운전면허번호</td><td><input type=\"text\" name=\"dlLicenseNum\"></td></tr><tr><td>운전자사진등록</td><td><input type=\"file\" name=\"picLoc\"></td></tr>");
		$("form").attr("action","/kosta_project_final_taxi/driver.do");
		$("table.modify").css({
			"font-family":"myFont",
			"text-align":"center",
			"margin-top":"30px",
			"width":"400px"
		});
		
		$("table.modify th").css({
			"padding":"10px"
		});
		
		$("table.modify td").css({
			"border": "2px solid white",
			"padding": "10px",
			"text-align":"center",
			"min-width":"200px"
		});	
		$("#upgrade").css({
			"display": "none"
		});	
		$("input[type=text]").css({
			"width":"200px",
			"text-align":"center"
		});
		$("input[type=password]").css({
			"width":"200px",
			"text-align":"center"
		});
		driverForm = false;
	}
}

function upgradeManager(){
	if(driverForm){
		$("#modify_address").after("<tr><td>회원종류</td><td><input type=\"text\" name=\"memberType\" disabled value=\"관리자\">");
		$("table.modify").css({
			"font-family":"myFont",
			"text-align":"center",
			"margin-top":"30px",
			"width":"400px"
		});
		
		$("table.modify th").css({
			"padding":"10px"
		});
		
		$("table.modify td").css({
			"border": "2px solid white",
			"padding": "10px",
			"text-align":"center",
			"min-width":"200px"
		});	
		$("#upgrade").css({
			"display": "none"
		});	
		$("input[type=text]").css({
			"width":"200px",
			"text-align":"center"
		});
		$("input[type=password]").css({
			"width":"200px",
			"text-align":"center"
		});
		driverForm = false;
	}
}
</script>

<h2>회원정보 수정 폼</h2>

<form method="post" action="/kosta_project_final_taxi/modify.do" name="f1"
          onsubmit="return formCheck()" >
<input type="hidden" name="method" value="modifyMember">
<input type="hidden" name="memberId" value="${sessionScope.login_info.memberId }">
    <table class="modify" style="width:500px">
        <tr>
            <th>ID</th>
            <td>
            	<input type="text" name="memberId" value="${sessionScope.login_info.memberId}">
            </td>
        </tr>
        <tr>
            <th>Password</th>
            <td>
                <input type="password" name="password">
            </td>
        </tr>
        <tr>
            <th>전화번호</th>
            <td>
                <input type="text" name="phone" value="${sessionScope.login_info.phone }">
            </td>
        </tr>
        <tr>
            <th>이름</th>
            <td>
                <input type="text" name="name" value="${sessionScope.login_info.name }">
            </td>
        </tr>
        <tr id="modify_address">
            <th>주소</th>
            <td>
                <input type="text" name="address" value="${sessionScope.login_info.address }">
            </td>
        </tr>
        <tr> 
            <td colspan="2" >
                <input type="submit" value="수정">
                <input type="reset" value="다시작성">
                <input id="upgrade" type="button" value="택시운전사 신청" onclick="upgradeDriver()"/>
                <input id="managerRequest" type="button" value="관리자 신청" onclick="upgradeManager()"/>
            </td>
        </tr>
    </table>
</form>
